<template>
  <div class="page-card">
    <div class="page-card-content">
      <div class="item-title small-card-title">
        <span>报价（{{ total }}）</span>
        <div class="title-right">
          <span class="new-icon" @click="gotoNew()">新建</span>
          <!-- <span class="all-link" @click="gotoAll()">全部 <span class="el-icon-arrow-right" /> </span> -->
        </div>
      </div>
      <div class="card-item">
        <div v-if="list.length<=0&&list.length<=0" class="no-data">
          <img src="@/assets/images/no-data.png">
          <span>暂无数据</span>
        </div>
        <div class="card-item-list">
          <div v-for="l in list" :key="l.id" class="card-item-list-item">
            <div class="list-item-title">
              <img src="@/assets/images/icon-quote.png">
              <span class="name-link" @click="gotoDetail(l)">{{ l.no }}</span>
            </div>
            <div class="list-item-row">
              <div class="item-row-title">报价名称 :</div>
              <div class="item-row-content">
                <span class="name-link" @click="gotoDetail(l)">{{ l.name }}</span>
              </div>
            </div>
            <div class="list-item-row">
              <div class="item-row-title">金额（元）:</div>
              <div class="item-row-content">
                {{ l.amount |moneyFormat }}
              </div>
            </div>
            <div class="list-item-row">
              <div class="item-row-title">报价日期 :</div>
              <div class="item-row-content">
                {{ formatTime(l.date,'YYYY-MM-DD') }}
              </div>
            </div>

          </div>
        </div>

      </div>
      <div v-if="list.length>0" class="link-btn">
        <span class="all-link" @click="gotoAll()">查看全部 </span>
      </div>
    </div>
  </div>
</template>
<script>
import { getQuoteList } from '@/api/quote'
import { formatTime } from '@/utils/tools'

export default {
  name: 'CoantactCard',
  props: {
    customerId: {
      type: String,
      default: ''
    },
    customerName: {
      type: String,
      default: ''
    },
    quoteId: {
      type: String,
      default: ''
    },
    quoteNo: {
      type: String,
      default: ''
    }

  },
  data() {
    return {
      total: 0,
      list: []

    }
  },
  mounted() {
    getQuoteList({ customerId: this.customerId, quoteId: this.quoteId, currentPage: 1, pageSize: 2 }).then(res => {
      this.total = res.total
      this.list = res.records
    })
  },
  methods: {
    formatTime,
    //
    gotoAll() {
      this.gotoMainPage('quote', { customerId: this.customerId })
      // this.$router.push({ path: '/quote', query: { customerId: this.customerId }})
    },
    gotoDetail(l) {
      this.gotoMainPage('quote/info', { id: l.id })
    },
    gotoNew() {
      this.gotoMainPage('quote/add', {
        customerId: this.customerId,
        customerName: this.customerName
      })
    }
  }
}
</script>
